<?php
defined('IN_MAIN') or exit('Invalid Access!');

function get_user_short_detail_by_id($id){
 global $vars;
 $db=$vars["db"];
 if(strlen($id)){
  $sql="select id, ref, matrix_upline, matrix_position, placement_date, activated, activated_date, country from $db->users where id='$id'";
  $user=get_user_detail_sql($sql);
 }
 return $user;
}

function get_user_detail_by_id($id){
 global $vars;
 $db=$vars["db"];
 if(strlen($id)){
  $sql="select * from $db->users where id='$id'";
  $user=get_user_detail_sql($sql);
 }
 return $user;
}

function get_user_detail_by_code($code){ 
 global $vars; $db=$vars["db"]; 
 if(strlen($code)){  
 	$sql="select * from $db->users where code='$code'";  
 	$user=get_user_detail_sql($sql); 
 } 
 return $user;
}

function get_user_detail_by_username($username){
 global $vars;
 $db=$vars["db"];
 if(strlen($username)){
  $sql="select * from $db->users where username='$username'";
  $user=get_user_detail_sql($sql);
 }
 return $user;
}
            
function get_user_detail_by_email($email){
 global $vars;
 $db=$vars["db"];
 if(strlen($email)){
  $sql="select * from $db->users where email='$email'";
  $user=get_user_detail_sql($sql);
 }
 return $user;
}

function get_user_cf_by_upline_id($id,$pos){
 global $vars;
 $db=$vars["db"];
 if(strlen($id)){
  $sql="select a.id,a.rank_a,a.code,a.username,b.amount from $db->users a left join $db->member_cf_calc b on a.id=b.uid where a.matrix_upline='$id' and a.matrix_position='$pos'";
  $user=get_user_detail_sql($sql);
 }
 return $user;
}

function get_user_detail_sql($inSQL){
	global $vars;
	$db=$vars["db"];
	$r=mysql_query($inSQL);
	if($r && mysql_num_rows($r)){
		$ru=mysql_fetch_assoc($r);
	}
	return $ru;
}
?>